// import Mock from 'mockjs'
const loginRet = {
  'code': 0,
  'message': '操作成功',
  'data': {
    'id': 0,
    'name': '炒鸡管理员',
    'headImg': null,
    'remarks': '超级管理员admin',
    'roleId': 0,
    'merchantId': null,
    'merchantNo': null,
    'mobile': '15308032177',
    'type': '0',
    'defaultPasswordLogin': 'N',
    'merchantType': null,
    'parentMerchantId': null
  },
  'token': '6415489e3da7d5e81dc2bbebb662702e'
}

const users = {
  15308032177: {
    password: '123456'
  }
}

export default [
  {
    url: '/api/login',
    type: 'post',
    response: config => {
      const { mobile, password } = config.query
      const user = users[mobile]
      if (!user) {
        return loginRet
      }
      if (user.password !== password) {
        return {
          code: 1,
          message: '密码错误'
        }
      }

      return loginRet
    }
  },

  // 用户登录获取验证码
  {
    url: '/login/refurbishCode',
    type: 'get',
    response: config => {
      return {
        'code': 0,
        'message': '操作成功',
        'data': '1234'// Mock.mock('@string("number", 4)')
      }
    }
  },

  // user logout
  {
    url: '/login/logout',
    type: 'get',
    response: _ => {
      return {
        code: 0,
        data: 'success'
      }
    }
  }
]
